//
//  UIImage+Extension.swift
//  01-SinaWeibo
//
//  Created by 周英培 on 16/5/28.
//  Copyright © 2016年 周英培. All rights reserved.
//

import UIKit

//屏幕截图
extension UIImage {
    
    //获取当前屏幕
   class func sanpShotCurrentWindow() -> UIImage{
        
        let window = UIApplication.sharedApplication().keyWindow!
        
        //开启图形上下文
        UIGraphicsBeginImageContextWithOptions(window.bounds.size, false, 0)
        
        //将要显示的内容 写到图形上下文中
        window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: false)
        
        //从图形上下文中获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
       
        //关闭上下文
        UIGraphicsEndPDFContext()
        
        return image
    
    }


}